<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" placeholder="验证码">
    <button>发送验证码</button>
    <script>
        let btn=document.querySelector('button');
        btn.addEventListener('click',function(){
            let time=60;
            btn.disabled=true;
            let timer=setInterval(function(){//setInterval在一定时间内运行代码
                if(time==0){
                    clearInterval(timer);
                    btn.disabled=false;
                    btn.innerHTML='发送验证码';
                }else{
                    btn.innerHTML=time+'秒后重新发送';
                    time--;
                }
        },1000);
    });
    </script>
</body>
</html>